//
//  DropdownBoxModel.m
//  Demo
//
//  Created by MacPro on 15/12/14.
//  Copyright © 2015年 pccb. All rights reserved.
//

#import "DropdownBoxModel.h"

@implementation DropdownBoxModel

- (instancetype)initWithObject:(NSArray *)dataAry
{
    self = [super init];
    if(self){
        
        self.taxTypeArray = [NSMutableArray arrayWithCapacity:2];
        self.companyTypeArray = [NSMutableArray arrayWithCapacity:2];
        self.buyTimeArray = [NSMutableArray arrayWithCapacity:2];
        self.companyPhaseArray = [NSMutableArray arrayWithCapacity:2];

        
        NSInteger count = [dataAry count];
        for (int i = 0; i < count; i++) {
            NSDictionary *dcit = [dataAry objectAtIndex:i];
            
            NSInteger type = [[dcit objectForKey:@"type"] intValue];
            
            BoxTypeModel *boxType = [[BoxTypeModel alloc] initWithObject:dcit];
            
            switch (type) {
                case 1:
                {
                    [self.taxTypeArray addObject:boxType];
                    
                    break;
                }
                    
                case 2:
                {
                    [self.companyTypeArray addObject:boxType];
                    
                    break;
                }
                    
                case 3:
                {
                    [self.buyTimeArray addObject:boxType];
                    
                    break;
                }
                    
                case 4:
                {
                    [self.companyPhaseArray addObject:boxType];
                    
                    break;
                }
                    
                default:
                    break;
            }
            
            
        }
        
    }
    return self;
}

//"id": 1,
//"name": "小规模纳税人",
//"type": 2,
//"price": null

@end


@implementation BoxTypeModel

- (instancetype)initWithObject:(NSDictionary *)dataDict
{
    self = [super init];
    if(self){
        
        self.boxId = [dataDict objectForKey:@"id"];
        self.boxType = [dataDict objectForKey:@"type"];
        self.boxName = [dataDict objectForKey:@"name"];
        self.boxPrice = [dataDict objectForKey:@"price"];
    
    }
    
    return self;
    
}

@end
